<?php
/**
* Display the user preferences
*
* @author       Fabrice Douteaud <admin@clearbudget.net>
* @package      snippets
* @access       public
*/

/***********************************************************************

  Copyright (C) 2008  Fabrice Douteaud (admin@clearbudget.net)

    This file is part of ClearBudget.

    ClearBudget is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ClearBudget is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ClearBudget.  If not, see <http://www.gnu.org/licenses/>.


************************************************************************/
//prevent direct access
if(!defined('ENGINEON')) die('Direct access forbidden');
$userSettings = class_settings::getInstance();

$userSettings->getSettings();
?>
<div class="title"><img src="style/icons/computer_edit.png"/> <?php echo $keys->pageTitle_accountSettings; ?></div><br/>
<form action="index.php" method="post">
<input type="hidden" name="action" value="settings">
<?php
if($userSettings->secureAccess() && $userSettings->getPassword(true)!=false) {
  if($badCurrentPassword) echo '<div class="error"><blockquote>'.$keys->text_mustGivePasswordWarning.'</blockquote></div>';
  }
if($badUsername) echo '<div class="error"><blockquote>'.$keys->error_InvalidUsername.'</blockquote></div><br/>';
if($badPassword) echo '<div class="error"><blockquote>'.$keys->error_InvalidPassword.'</blockquote></div><br/>';
if($settingsSuccess) echo '<div class="success"><blockquote>'.$keys->error_UserSettingsSuccess.'</blockquote></div><br/>';
if($missingMandatoryUserSettings) echo '<div class="error"><blockquote>'.$keys->error_MissingMandatoryUserSettings.'</blockquote></div><br/>';
?>
<table class="tableReport">
<tr>
  <th><?php echo $keys->text_settingName; ?></th>
  <th><?php echo $keys->text_settingInput; ?></th>
</tr>
<tr><td><?php echo $keys->text_login; ?></td>
<td><input type="text" value="<?php echo $username; ?>" name="username" id="login"></td></tr>
<tr><td><?php echo $keys->text_password; ?></td>
<td><input type="password" value="" name="newPassword" id="newPassword"></td></tr>
<?php if(CB_RUN_MODE == 'FREE') { ?>
<tr><td><?php echo $keys->text_secureAccess; ?></td>
<td><select name="secureAccess" id="secureAccess">
<option value='0' <?php if($secureAccess === '0') echo 'selected';?>><?php echo $keys->text_no; ?></option>
<option value='1' <?php if($secureAccess == '1') echo 'selected';?>><?php echo $keys->text_yes; ?></option>
</select></td></tr>
<?php } ?>
<tr><td><?php echo $keys->text_language; ?>*</td>
<td><select name="language" id="language">
<?php
$languages = explode(',', AVAILABLELANGUAGE);
foreach($languages as $lang) {
  $key = 'link_SetLanguage'.strtoupper($lang);
  echo '<option value="'.$lang.'" ';
  if($language == $lang) echo 'selected';
  echo '>'.$keys->$key.'</option>';
  }
?>
</select></td></tr>
<tr><td><?php echo $keys->text_currency; ?>*</td>
<td><select name="currency" id="currency">
<?php
$currencies = explode(',', AVAILABLECURRENCY);
foreach($currencies as $curr) {
  $key = 'text_'.$curr;
  echo '<option value="'.$curr.'" ';
  if($currency == $curr) echo 'selected';
  echo '>'.$keys->$key.'</option>';
  }
?>
</select></td></tr>
<tr><td colspan="2"  style="text-align:center" >
<?php if($userSettings->secureAccess()) { ?><img src="style/icons/error.png"/> <?php echo $keys->text_mustGivePasswordWarning; ?>: <input type="password" value="" name="currentPassword" id="currentPassword"><?php } ?>
<input type="submit" class="submit" name="submit" value="<?php echo $keys->link_save; ?>">
</td></tr>
</table>
</form>
